<template>
	<div class="content">
		<div class="content-header">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item>移动管理</el-breadcrumb-item>
				<el-breadcrumb-item>
					<b>意见与反馈</b>
				</el-breadcrumb-item>
			</el-breadcrumb>
		</div>
		<div class="content-body">
			<el-scrollbar>
				<div class="panel">
					<el-form :model="appFeedbackSearchForm" ref="appFeedbackSearchForm" inline label-width="100px">
						<el-row>
							<el-col :md="8">
								<el-form-item label="反馈内容">
									<el-input v-model="appFeedbackSearchForm.content"></el-input>
								</el-form-item>
							</el-col>
							<el-col :md="8">
								<el-form-item label="状态">
									<el-select v-model="appFeedbackSearchForm.status" placeholder="全部">
										<el-option v-for="item in statusList" :key="item.id" :label="item.name"
											:value="item.id"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :md="8" class="search-btn">
								<div class="search-btn-right">
									<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
									<el-button icon="el-icon-refresh" @click="resetForm">重置</el-button>
								</div>
							</el-col>
						</el-row>
					</el-form>
					<el-table :data="tableData" border stripe style="width: 100%">
						<el-table-column label="序号" width="60" header-align="left" align="center">
							<template slot-scope="scope">{{scope.$index + 1 + (tableCurrentPage-1)*tablePageSize}}</template>
						</el-table-column>
						<el-table-column label="反馈内容" prop="content"></el-table-column>
						<el-table-column label="状态" prop="status">
							<template slot-scope="scope">
								<span v-if="scope.row.status == '1'">待处理</span>
								<span v-else-if="scope.row.status == '2'">已处理</span>
								<span v-else>无需处理</span>
							</template>
						</el-table-column>
						<el-table-column label="操作" min-width="100px">
							<template slot-scope="scope">
								<el-button type="info" @click="handleDetail(scope.row.id)">详情</el-button>
							</template>
						</el-table-column>
					</el-table>
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:current-page.sync="tableCurrentPage" :page-sizes="[10, 20, 30, 50]"
						:page-size.sync="tablePageSize" layout="total, jumper, prev, pager, next, sizes"
						:total="tableTotal"></el-pagination>
				</div>
			</el-scrollbar>
			<AppFeedback ref="appFeedback"></AppFeedback>
		</div>
	</div>
</template>

<script>
	import AppFeedback from "./AppFeedback";
	export default {
		components: {
			AppFeedback
		},
		data() {
			return {
				appFeedbackSearchForm: {
					content: null,
					status: '1'
				},
				statusList: [
					{	
						id: "1",
						name: "待处理"
					},
					{
						id: "2",
						name: "已处理"
					},
					{
						id: "3",
						name: "无需处理"
					}
				],
				tableTotal: 0,
				tableCurrentPage: 1,
				tablePageSize: 10,
				tableData: []
			};
		},
		mounted() {
			this.getTableData(this.tableCurrentPage, this.tablePageSize);
		},
		methods: {
			handleSizeChange(val) {
				this.getTableData(this.tableCurrentPage, val);
			},
			handleCurrentChange(val) {
				this.getTableData(val, this.tablePageSize);
			},
			handleSearch() {
				this.getTableData(this.tableCurrentPage, this.tablePageSize);
			},
			getTableData(page, pageSize) {

				let pageParams = '?page=' + page + '&rows=' + pageSize;

				this.$api.post('/appFeedback/findByPage' + pageParams, this.appFeedbackSearchForm).then(
					response => {
						this.tableData = response.data.list;
						this.tableTotal = response.data.total;
					}
				);
			},
			resetForm() {
				this.appFeedbackSearchForm = {
					content: null,
					status: null
				};
				this.getTableData(1, this.tablePageSize);
			},
			handleDetail(id) {
				this.$refs.appFeedback.initForm(id);
			}
		}
	};
</script>
